package org.gap.service;

import java.util.List;
import java.util.Set;

import org.gap.domain.Relations;
import org.gap.domain.RelationsTiers;
import org.gap.domain.Tiers;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class RelationsTiersServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected RelationsTiersService service;

	/**
	 * Instantiates a new RelationsTiersServiceTest.
	 *
	 */
	public RelationsTiersServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findRelationsTiersByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findRelationsTiersByPrimaryKey 
		Integer rltTiersParent = 0;
		Integer rltTiersFils = 0;
		String rltRelation = null;
		RelationsTiers response = null;
		response = service.findRelationsTiersByPrimaryKey(rltTiersParent, rltTiersFils, rltRelation);
		// TODO: JUnit - Add assertions to test outputs of operation: findRelationsTiersByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Save an existing Tiers entity
	 * 
	 */
	@Test
	public void saveRelationsTiersTiersByRltTiersFils() {
		// TODO: JUnit - Populate test inputs for operation: saveRelationsTiersTiersByRltTiersFils 
		Integer rltTiersParent_1 = 0;
		Integer rltTiersFils_1 = 0;
		String rltRelation_1 = null;
		Tiers related_tiersbyrlttiersfils = new org.gap.domain.Tiers();
		RelationsTiers response = null;
		response = service.saveRelationsTiersTiersByRltTiersFils(rltTiersParent_1, rltTiersFils_1, rltRelation_1, related_tiersbyrlttiersfils);
		// TODO: JUnit - Add assertions to test outputs of operation: saveRelationsTiersTiersByRltTiersFils
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Tiers entity
	 * 
	 */
	@Test
	public void deleteRelationsTiersTiersByRltTiersParent() {
		// TODO: JUnit - Populate test inputs for operation: deleteRelationsTiersTiersByRltTiersParent 
		Integer relationstiers_rltTiersParent = 0;
		Integer relationstiers_rltTiersFils = 0;
		String relationstiers_rltRelation = null;
		Integer related_tiersbyrlttiersparent_tieTiers = 0;
		RelationsTiers response = null;
		response = service.deleteRelationsTiersTiersByRltTiersParent(relationstiers_rltTiersParent, relationstiers_rltTiersFils, relationstiers_rltRelation, related_tiersbyrlttiersparent_tieTiers);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteRelationsTiersTiersByRltTiersParent
	}

	/**
	 * Operation Unit Test
	 * Save an existing Tiers entity
	 * 
	 */
	@Test
	public void saveRelationsTiersTiersByRltTiersParent() {
		// TODO: JUnit - Populate test inputs for operation: saveRelationsTiersTiersByRltTiersParent 
		Integer rltTiersParent_2 = 0;
		Integer rltTiersFils_2 = 0;
		String rltRelation_2 = null;
		Tiers related_tiersbyrlttiersparent = new org.gap.domain.Tiers();
		RelationsTiers response = null;
		response = service.saveRelationsTiersTiersByRltTiersParent(rltTiersParent_2, rltTiersFils_2, rltRelation_2, related_tiersbyrlttiersparent);
		// TODO: JUnit - Add assertions to test outputs of operation: saveRelationsTiersTiersByRltTiersParent
	}

	/**
	 * Operation Unit Test
	 * Delete an existing RelationsTiers entity
	 * 
	 */
	@Test
	public void deleteRelationsTiers() {
		// TODO: JUnit - Populate test inputs for operation: deleteRelationsTiers 
		RelationsTiers relationstiers = new org.gap.domain.RelationsTiers();
		service.deleteRelationsTiers(relationstiers);
	}

	/**
	 * Operation Unit Test
	 * Return a count of all RelationsTiers entity
	 * 
	 */
	@Test
	public void countRelationsTierss() {
		Integer response = null;
		response = service.countRelationsTierss();
		// TODO: JUnit - Add assertions to test outputs of operation: countRelationsTierss
	}

	/**
	 * Operation Unit Test
	 * Save an existing RelationsTiers entity
	 * 
	 */
	@Test
	public void saveRelationsTiers() {
		// TODO: JUnit - Populate test inputs for operation: saveRelationsTiers 
		RelationsTiers relationstiers_1 = new org.gap.domain.RelationsTiers();
		service.saveRelationsTiers(relationstiers_1);
	}

	/**
	 * Operation Unit Test
	 * Load an existing RelationsTiers entity
	 * 
	 */
	@Test
	public void loadRelationsTierss() {
		Set<RelationsTiers> response = null;
		response = service.loadRelationsTierss();
		// TODO: JUnit - Add assertions to test outputs of operation: loadRelationsTierss
	}

	/**
	 * Operation Unit Test
	 * Save an existing Relations entity
	 * 
	 */
	@Test
	public void saveRelationsTiersRelations() {
		// TODO: JUnit - Populate test inputs for operation: saveRelationsTiersRelations 
		Integer rltTiersParent_3 = 0;
		Integer rltTiersFils_3 = 0;
		String rltRelation_3 = null;
		Relations related_relations = new org.gap.domain.Relations();
		RelationsTiers response = null;
		response = service.saveRelationsTiersRelations(rltTiersParent_3, rltTiersFils_3, rltRelation_3, related_relations);
		// TODO: JUnit - Add assertions to test outputs of operation: saveRelationsTiersRelations
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Tiers entity
	 * 
	 */
	@Test
	public void deleteRelationsTiersTiersByRltTiersFils() {
		// TODO: JUnit - Populate test inputs for operation: deleteRelationsTiersTiersByRltTiersFils 
		Integer relationstiers_rltTiersParent_1 = 0;
		Integer relationstiers_rltTiersFils_1 = 0;
		String relationstiers_rltRelation_1 = null;
		Integer related_tiersbyrlttiersfils_tieTiers = 0;
		RelationsTiers response = null;
		response = service.deleteRelationsTiersTiersByRltTiersFils(relationstiers_rltTiersParent_1, relationstiers_rltTiersFils_1, relationstiers_rltRelation_1, related_tiersbyrlttiersfils_tieTiers);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteRelationsTiersTiersByRltTiersFils
	}

	/**
	 * Operation Unit Test
	 * Return all RelationsTiers entity
	 * 
	 */
	@Test
	public void findAllRelationsTierss() {
		// TODO: JUnit - Populate test inputs for operation: findAllRelationsTierss 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<RelationsTiers> response = null;
		response = service.findAllRelationsTierss(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllRelationsTierss
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Relations entity
	 * 
	 */
	@Test
	public void deleteRelationsTiersRelations() {
		// TODO: JUnit - Populate test inputs for operation: deleteRelationsTiersRelations 
		Integer relationstiers_rltTiersParent_2 = 0;
		Integer relationstiers_rltTiersFils_2 = 0;
		String relationstiers_rltRelation_2 = null;
		String related_relations_relRelation = null;
		RelationsTiers response = null;
		response = service.deleteRelationsTiersRelations(relationstiers_rltTiersParent_2, relationstiers_rltTiersFils_2, relationstiers_rltRelation_2, related_relations_relRelation);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteRelationsTiersRelations
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
